﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QTreeWidget>
#include <QTableWidgetItem>

DigitalArchive::DigitalArchive(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->setGeometry(200,100,1450,950);

    docManage=new DocManage(this);
    rankParallel=new RankParallel(this);
    dirManage=new DirManage(this);
    postChange=new PostChange(this);
    cadrePortrait= new CadrePortrait(this);
    datajieshou = new shujujieshou(this);
    datashangbao = new ShuJuShangBao(this);
    ruanjian = new renmianruanjian(this);
    renmianbiaodaoru = new qualifyDocu(this);
    pingbanmingce = new padbook(this);
    huiyifangan = new meetingWay(this);
    inform = new Inform(this);
    cadrestatistic = new statistic(this);
    unitmingce = new Widget(this);
    cadreinfo = new CadreInfo(this);
    cadreroll = new CadreRoll(this);
    colwidget = new COLwidget(this);
    fowidget = new FOwidget(this);
    frwidget = new FRwidget(this);
    fswidget = new FSwidget(this);
    mrwidget = new MRWidget(this);
    mswidget = new MSwidget(this);
    digitalarchive = new DigitalArchiveFrm(this);

    ui->stackedWidget->addWidget(docManage);
    ui->stackedWidget->addWidget(rankParallel);
    ui->stackedWidget->addWidget(dirManage);
    ui->stackedWidget->addWidget(postChange);
    ui->stackedWidget->addWidget(cadrePortrait);
    ui->stackedWidget->addWidget(datajieshou);
    ui->stackedWidget->addWidget(datashangbao);
    ui->stackedWidget->addWidget(ruanjian);
    ui->stackedWidget->addWidget(renmianbiaodaoru);
    ui->stackedWidget->addWidget(pingbanmingce);
    ui->stackedWidget->addWidget(huiyifangan);
    ui->stackedWidget->addWidget(inform);
    ui->stackedWidget->addWidget(cadrestatistic);
    ui->stackedWidget->addWidget(unitmingce);
    ui->stackedWidget->addWidget(cadreinfo);
    ui->stackedWidget->addWidget(cadreroll);
    ui->stackedWidget->addWidget(colwidget);
    ui->stackedWidget->addWidget(fowidget);
    ui->stackedWidget->addWidget(frwidget);
    ui->stackedWidget->addWidget(fswidget);
    ui->stackedWidget->addWidget(mrwidget);
    ui->stackedWidget->addWidget(mswidget);
    ui->stackedWidget->addWidget(digitalarchive);

    ui->stackedWidget->setCurrentWidget(cadreinfo);

    //节点展开
    ui->treeWidget->setHeaderHidden(true);
    ui->treeWidget->expandAll();

    //ui->treeWidget->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);

    //文书管理-添加记录->弹出干部信息查询界面
    connect(docManage, SIGNAL(findCadre()), this, SLOT(cadreSearch()));
    //干部信息查询界面->idNum->文书管理
    connect(&cadSearch,SIGNAL(sendRecvNum(QString)),docManage,SLOT(dealRecvNum(QString)));
    //目录管理-档案编辑->弹出干部档案信息编辑界面
    connect(dirManage, SIGNAL(fileEdit()), this, SLOT(fileEditSlot()));
    //职务变动-档案编辑->弹出干部档案信息编辑界面
    connect(postChange, SIGNAL(fileEdit()), this, SLOT(fileEditSlot()));
    //目录管理-打印->弹出目录打印操作界面
    //connect(frm3, SIGNAL(printSignal()), this, SLOT(printDia()));
    //职务变动-打印->弹出目录打印操作界面
    //connect(frm4, SIGNAL(printSignal()), this, SLOT(printDia()));


}

DigitalArchive::~DigitalArchive()
{
    delete ui;
}

//干部查询界面
void DigitalArchive::cadreSearch()
{
    cadSearch.show();
}

//档案信息编辑界面
void DigitalArchive::fileEditSlot()
{
    fileInfoEdit.show();
}

//打印选择对话框
void DigitalArchive::printDia()
{
//    priD.show();
}

//切换页面
void DigitalArchive::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
{
    //QTreeWidgetItem *item =new QTreeWidgetItem();
    item = ui->treeWidget->currentItem();
    QString str = item->text(column);
    qDebug() << str;

    if(str == "文书管理")
    {
         ui->stackedWidget->setCurrentIndex(0);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "职级并行")
    {
        ui->stackedWidget->setCurrentIndex(1);
        //ui->stackedWidget->setCurrentWidget(rankParallel);
    }
    if(str == "目录管理")
    {
        ui->stackedWidget->setCurrentIndex(2);
        //ui->stackedWidget->setCurrentWidget(dirManage);
    }
    if(str == "职务变动")
    {
        ui->stackedWidget->setCurrentIndex(3);
        //ui->stackedWidget->setCurrentWidget(postChange);
    }
    if(str == "干部画像")
    {
        ui->stackedWidget->setCurrentIndex(4);
        //ui->stackedWidget->setCurrentWidget(postChange);
    }
    if(str == "数据接收")
    {
         ui->stackedWidget->setCurrentIndex(5);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "数据上报")
    {
         ui->stackedWidget->setCurrentIndex(6);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "任免软件")
    {
         ui->stackedWidget->setCurrentIndex(7);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "任免表导入")
    {
         ui->stackedWidget->setCurrentIndex(8);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "平板名册")
    {
         ui->stackedWidget->setCurrentIndex(9);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "会议方案")
    {
         ui->stackedWidget->setCurrentIndex(10);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "通知与提醒")
    {
         ui->stackedWidget->setCurrentIndex(11);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "公务员统计")
    {
         ui->stackedWidget->setCurrentIndex(12);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "单位名册")
    {
         ui->stackedWidget->setCurrentIndex(13);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "干部信息")
    {
         ui->stackedWidget->setCurrentIndex(14);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "干部名册")
    {
         ui->stackedWidget->setCurrentIndex(15);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "查阅审批")
    {
         ui->stackedWidget->setCurrentIndex(16);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "档案接收")
    {
         ui->stackedWidget->setCurrentIndex(18);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "档案转出")
    {
         ui->stackedWidget->setCurrentIndex(17);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "档案报送")
    {
         ui->stackedWidget->setCurrentIndex(19);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "材料接收")
    {
         ui->stackedWidget->setCurrentIndex(20);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "材料报送")
    {
         ui->stackedWidget->setCurrentIndex(21);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
    if(str == "档案编辑")
    {
         ui->stackedWidget->setCurrentIndex(22);
         //ui->stackedWidget->setCurrentWidget(docManage);
    }
}

//切换页面
//void MainWindow::WidChange()
//{
//       //获取页面的数量
//       int nCount = ui->stackedWidget->count();
//       //获取当前页面的索引
//       int nIndex = ui->stackedWidget->currentIndex();
//       //获取下一个需要显示的页面索引
//       nIndex++;

//       //当需要显示的页面索引大于等于总页面时，切换至首页
//       if (nIndex >= nCount)
//       {
//           nIndex = firstIndex;
//       }

//       //显示当前页面
//       qDebug()<<nIndex;
//       ui->stackedWidget->setCurrentIndex(nIndex);

//}
